/**
 * 自定义标题栏样式
 * 透明背景，适配macOS和Windows
 */

/* 标题栏容器 */
.custom-titlebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 30px !important;
  background: transparent !important; /* 透明背景 */
  display: flex !important;
  align-items: center !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 10000 !important;
  -webkit-app-region: drag; /* 允许拖拽窗口 */
  user-select: none;
}

/* 标题栏左侧区域 */
.titlebar-left {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex: 1 !important;
  padding-left: 75px !important; /* 为macOS红绿黄按钮和头像留出空间 */
  margin: 0 !important;
}

/* 标题栏用户头像 - 独立悬浮模块 */
.titlebar-avatar {
  position: fixed;  /* 使用fixed定位，完全独立 */
  left: 13.1px;     /* 导航栏中央对齐: (67-40.8)/2 = 13.1px */
  top: 29px;        /* 下移12px (17+12=29) */
  width: 40.8px;
  height: 40.8px;
  border-radius: 50%;
  overflow: hidden;
  background: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 10001;  /* 高于标题栏的1000 */
  -webkit-app-region: no-drag; /* 头像区域不可拖拽 */
}

.titlebar-avatar:hover {
  transform: scale(1.05);
}

.titlebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 标题文字 */
.titlebar-title {
  display: none; /* 隐藏标题文字 */
  font-size: 13px;
  font-weight: 500;
  color: #333;
  letter-spacing: 0.3px;
}

/* 标题栏右侧区域 */
.titlebar-right {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding-right: 9px !important;
  margin: 0 !important;
}

/* 窗口控制按钮 */
.titlebar-controls {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 40px !important;
  height: 30px !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background-color 0.2s;
  font-size: 14px !important;
  color: #666 !important;
  font-family: "Segoe MDL2 Assets", sans-serif;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
}

.titlebar-btn span {
  font-size: 14px !important;
  line-height: 1 !important;
  display: block !important;
}

.titlebar-btn:hover {
  background: rgba(0, 0, 0, 0.06) !important;
}

.titlebar-btn:active {
  background: rgba(0, 0, 0, 0.1) !important;
}

.titlebar-btn.close:hover {
  background: #e81123 !important;
  color: white !important;
}

.titlebar-btn.close:active {
  background: #c50d1b !important;
}

/* 云同步按钮样式 */
.titlebar-btn.cloud-sync {
  width: 40px !important;
  height: 30px !important;
}

.titlebar-btn.cloud-sync svg {
  width: 19px !important;
  height: 19px !important;
  display: block !important;
  flex-shrink: 0 !important;
}

/* 最小化按钮样式 */
.titlebar-btn.minimize span {
  transform: translateY(-1px) !important;
}

/* 最大化按钮样式 */
.titlebar-btn.maximize span {
  font-size: 15px !important;
}

/* 关闭按钮样式 */
.titlebar-btn.close span {
  font-size: 13px !important;
}

/* 所有平台统一样式 - 头像定位已在上方定义 */

.titlebar-left {
  padding-left: 75px; /* 头像 + 间距 */
}

/* 调整主内容区，为标题栏留出空间和透明边距 */
body {
  padding-top: 30px;
  padding-right: 9px;
  padding-bottom: 9px;
}

/* 登录页面不需要右侧和底部边距 */
body.login-page {
  padding-right: 0;
  padding-bottom: 0;
}

/* 侧边栏也需要调整 */
.sidebar {
  top: 40px;
  bottom: 9px;
  height: auto;
}

/* 主容器调整 */
.main-container {
  padding-top: 0;
  margin-top: 0;
}

/* 透明效果增强 */
.custom-titlebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent; /* 完全透明 */
  /* backdrop-filter: blur(10px); 已移除模糊效果 */
  /* -webkit-backdrop-filter: blur(10px); 已移除模糊效果 */
  z-index: -1;
  /* border-bottom: 已移除边框 */
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  .titlebar-title {
    color: #ffffff;
  }
  
  .titlebar-btn {
    color: #ffffff;
  }
  
  .custom-titlebar::before {
    background: transparent; /* 完全透明 */
    /* border-bottom: 已移除边框 */
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .custom-titlebar {
    height: 30px;
  }
  
  .titlebar-avatar {
    width: 37.12px;
    height: 37.12px;
    left: 14.94px;  /* 移动端导航栏中央对齐: (67-37.12)/2 = 14.94px */
    top: 18px;
  }
  
  .titlebar-left {
    padding-left: 65px;
  }
  
  .titlebar-title {
    font-size: 11px;
  }
  
  body {
    padding-top: 30px;
    padding-right: 9px;
    padding-bottom: 9px;
  }
  
  body.login-page {
    padding-right: 0;
    padding-bottom: 0;
  }
  
  .sidebar {
    top: 40px;
    bottom: 9px;
    height: auto;
  }
}

/* 完全透明模式（可选） */
.custom-titlebar.fully-transparent::before {
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
}

/* 悬停时显示背景 */
.custom-titlebar.hover-visible::before {
  opacity: 0;
  transition: opacity 0.3s;
}

.custom-titlebar.hover-visible:hover::before {
  opacity: 1;
}

/* 用户菜单 */
.user-menu {
  position: fixed;
  left: 63.1px;  /* 向左移动8px (71.1 - 8 = 63.1) */
  top: 30px;     /* 向上移动15px (45 - 15 = 30) */
  width: 240px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease-out;
  z-index: 10002;
  -webkit-app-region: no-drag;
}

.user-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 菜单头部 */
.user-menu-header {
  display: flex;
  align-items: center;
  padding: 16px 12px 12px;
  gap: 10px;
}

.user-menu-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.user-menu-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu-info {
  flex: 1;
  min-width: 0;
}

.user-menu-name {
  font-size: 15px;
  font-weight: 600;
  color: #000000;
  margin-bottom: 4px;
}

.user-menu-level {
  font-size: 12px;
  color: #999999;
}

.user-menu-sign-btn {
  padding: 4px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #ffffff;
  font-size: 12px;
  color: #666666;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.user-menu-sign-btn:hover {
  background: #f5f5f5;
  border-color: #d0d0d0;
}

/* 签名输入框 */
.user-menu-signature {
  padding: 0 12px 12px;
}

.user-menu-signature input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.user-menu-signature input:focus {
  border-color: #0084F1;
}

.user-menu-signature input::placeholder {
  color: #cccccc;
}

/* 分割线 */
.user-menu-divider {
  height: 1px;
  background: #f0f0f0;
  margin: 8px 0;
}

/* 菜单项 */
.user-menu-items {
  padding: 4px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  color: #333333;
}

.user-menu-item:hover {
  background: #f5f5f5;
}

.user-menu-item .menu-icon {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  color: #666666;
  flex-shrink: 0;
}

.user-menu-item span {
  flex: 1;
}

.user-menu-item .menu-arrow {
  width: 12px;
  height: 12px;
  color: #999999;
  flex-shrink: 0;
}

/* 退出登录项特殊样式 */
#menuLogout {
  color: #ff4d4f;
}

#menuLogout:hover {
  background: #fff1f0;
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  /* 用户菜单始终保持白色背景 */
  .user-menu {
    background: #ffffff !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  
  .user-menu-name {
    color: #000000 !important;
  }
  
  .user-menu-level {
    color: #999999 !important;
  }
  
  .user-menu-sign-btn {
    background: #ffffff !important;
    border-color: #e0e0e0 !important;
    color: #666666 !important;
  }
  
  .user-menu-sign-btn:hover {
    background: #f5f5f5 !important;
  }
  
  .user-menu-signature input {
    background: #ffffff !important;
    border-color: #e0e0e0 !important;
    color: #333333 !important;
  }
  
  .user-menu-divider {
    background: #f0f0f0 !important;
  }
  
  .user-menu-item {
    color: #333333 !important;
  }
  
  .user-menu-item:hover {
    background: #f5f5f5 !important;
  }
  
  #menuLogout:hover {
    background: #f5f5f5 !important;
  }
}
